<template>
  <div>
    <el-dialog
      :title="dialogTitle"
      :visible.sync="show"
      width="75%"
      :before-close="close"
      center
      >
      <el-form :model="addForm" ref="addForm" label-width="100px">
        <el-form-item label="uid：">
          <el-input disabled v-model="addForm.pid"></el-input>
        </el-form-item>
        <el-form-item label="名称：">
          <el-input v-model="addForm.name" @keyup.enter.native="addBuilding"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="addBuilding">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
// import {buildingadd} from '../../utils/utils'
import axios from 'axios'
import {mapState} from 'vuex'
export default {
    props:{
      show:{
        type: Boolean,
        default:false
      }
    },
    data() {
      return {
        
      };
    },
    computed:{
      ...mapState({
        dialogTitle: state => state.building.dialogTitle,
        addForm: state => state.building.addForm,
      })
    },
    methods: {
      close() {
        this.$emit('close',false)
      },
      addBuilding(){
        axios.post('/api/building/add',this.addForm).then(res=>{
          const {errCode} = res.data
          if(errCode == 10000){
            this.$emit("close", false, undefined, undefined ,1);
            this.$refs.addForm.resetFields();
          }
        })
      }
    }
  };
</script>

<style scoped>

</style>